<script setup>
import { ref } from "vue";
import { getUserArtist } from "../../../apis/user";
import { createWindow } from "../../../utils/ipcRenderer";

const playList = ref([]);

const getInit = () => {
  getUserArtist({}).then((res) => {
    playList.value = res.data;
  });
};

getInit();

const handleSinger = (id) => {
  createWindow({
    windowName: "singerDetail",
    path: "singerDetail",
    width: 1200,
    height: 820,
    param: { id: id },
  });
};
</script>

<template>
  <div class="singer_cotainer">
    <div v-if="playList.length>0" class="singer_wrap">
      <div
        @click="handleSinger(item.id)"
        v-for="(item, index) in playList"
        :key="index"
        class="item"
      >
        <el-image :src="item.img1v1Url+`${'?param=300y300'}}`" fit="cover"></el-image>
        <div class="name">{{ item.name }}</div>
      </div>
    </div>
    <div v-else>
        <el-empty description="暂无艺人"></el-empty>
      </div>
  </div>
</template>

<style scoped lang="scss">
.singer_wrap {
  display: grid;
  justify-content: space-around;
  align-content: center;
  grid-template-columns: repeat(auto-fill, 16vw);
  .item {
    text-align: center;
    .el-image {
      border-radius: 50%;
    }
    .name {
      font-size: 18px;
      font-weight: 600;
      margin-top: 10px;
    }
  }
}
</style>
